package com.yidu.ruifeng_logistics.service.impl;

import com.yidu.ruifeng_logistics.entity.LogisticsExpend;
import com.yidu.ruifeng_logistics.dao.LogisticsExpendDao;
import com.yidu.ruifeng_logistics.service.LogisticsExpendService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 支出表(LogisticsExpend)表服务实现类
 *
 * @author makejava
 * @since 2021-03-09 14:24:38
 */
@Service("logisticsExpendService")
public class LogisticsExpendServiceImpl implements LogisticsExpendService {
    @Resource
    private LogisticsExpendDao logisticsExpendDao;

    /**
     * 通过ID查询单条数据
     *
     * @param expendId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsExpend queryById(Integer expendId) {
        return this.logisticsExpendDao.queryById(expendId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsExpend> queryAllByLimit(int offset, int limit) {
        return this.logisticsExpendDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsExpend 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsExpend insert(LogisticsExpend logisticsExpend) {
        this.logisticsExpendDao.insert(logisticsExpend);
        return logisticsExpend;
    }

    /**
     * 修改数据
     *
     * @param logisticsExpend 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsExpend update(LogisticsExpend logisticsExpend) {
        this.logisticsExpendDao.update(logisticsExpend);
        return this.queryById(logisticsExpend.getExpendId());
    }

    /**
     * 通过主键删除数据
     *
     * @param expendId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer expendId) {
        return this.logisticsExpendDao.deleteById(expendId) > 0;
    }

    @Override
    public List<LogisticsExpend> queryAll(LogisticsExpend logisticsExpend) {
        return this.logisticsExpendDao.queryAll(logisticsExpend);
    }

}
